package homework1121;

import java.io.File;
public class FileDetect {
    public static void main(String[] args) {
        int jpgCount = 0;
        int mp4Count = 0;
        int txtCount = 0;
        int mp3Count = 0;
        File f = new File("./homework1121/test");
        if(f.exists() && f.isDirectory()) {
            File[] files = f.listFiles();
            for( File file : files){
                if(file.getName().endsWith(".jpg")){
                    jpgCount++;
                }
                else if(file.getName().endsWith(".mp4")){
                    mp4Count++;
                }
                else if(file.getName().endsWith(".txt")){
                    txtCount++;
                }
                else if(file.getName().endsWith(".mp3")){
                    mp3Count++;
                }
            }
        }

        System.out.println("jpg: " + jpgCount + " " + "mp4: " + mp4Count + " " + "txt: "
                                                    + txtCount + " " + "mp3: " + mp3Count);

    }
}
